//
//  DianTaiListTableViewCell.m
//  ProJectB_1
//
//  Created by lanou3g on 16/8/15.
//  Copyright © 2016年 yangshukai. All rights reserved.
//

#import "DianTaiListTableViewCell.h"
#import "DianTaiListModel.h"

@implementation DianTaiListTableViewCell

- (void)setDataWithModel:(DianTaiListModel *)model{
    _descLabel.text = model.desc;
    _descLabel.font = [UIFont fontWithName:@"STHeitiSC-Light" size:17];
    _LabelHeight.constant = [self stringHeight:_descLabel.text];
    _countLable.text = [NSString stringWithFormat:@"%@ ☺︎",model.count];
    [_coverimg sd_setImageWithURL:[NSURL URLWithString:model.coverimg]];
    [_icon sd_setImageWithURL:[NSURL URLWithString:model.userinfo[@"icon"]]];
    _uname.text = model.userinfo[@"uname"];
//    [self setBackgroundView:[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"DianTaicell"]]];
//    self.backgroundColor = [UIColor colorWithHexCode:@"#01f87f"];
    
}
- (CGFloat)stringHeight:(NSString *)aString{
    CGRect temp = [aString boundingRectWithSize:CGSizeMake(355, 10000) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:17]} context:nil];
    return temp.size.height;
}

- (void)drawRect:(CGRect)rect{
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context, [UIColor clearColor].CGColor);
    CGContextFillRect(context, rect);
    
    //上分割线
//    CGContextSetStrokeColorWithColor(context, [UIColor colorWithRed:arc4random()%255/256.0 green:arc4random()%255/256.0 blue:arc4random()%255/256.0 alpha:1].CGColor);
//    CGContextStrokeRect(context, CGRectMake(0, 0, rect.size.width, 1));
    
    //下分割线
    CGContextSetStrokeColorWithColor(context, [UIColor colorWithRed:arc4random()%255/256.0 green:arc4random()%255/256.0 blue:arc4random()%255/256.0 alpha:1].CGColor);
    CGContextStrokeRect(context, CGRectMake(0, rect.size.height, rect.size.width, 10));
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
